package com.dingwen.sprboojwtstu.controller;

import com.dingwen.sprboojwtstu.entity.UserEntity;
import com.dingwen.sprboojwtstu.result.Result;
import com.dingwen.sprboojwtstu.result.ResultGenerator;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * user controller
 *
 * @author dingwen
 * 2021.05.31 13:56
 */
@Api(tags = "用户")
@RestController
@RequestMapping("/user")
public class UserController {

    /**
     * 查询用户列表
     *
     * @return {@link Result}
     */
    @ApiOperation("查询用户列表")
    @GetMapping("/users")
    public Result get() {
        List<UserEntity> userEntityList = new ArrayList<>();
        userEntityList.add(UserEntity.builder().username("lucy").password("123456").permissionList(Arrays.asList("admin", "test")).build());
        userEntityList.add(UserEntity.builder().username("carry").password("123456").permissionList(Arrays.asList("admin", "test")).build());
        return ResultGenerator.genOkResult(userEntityList);
    }
}
